package com.tuanzi.loan.web.bean.statistics;

import com.google.common.collect.Lists;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.request.statistics.RegistrationStatRequest;
import com.tuanzi.loan.vo.response.statistics.RegistrationStatResponse;
import com.tuanzi.loan.web.configuration.JSFListingBean;
import com.tuanzi.loan.web.lazy.statistics.RegistrationStatLazyDataModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import java.util.List;

/**
* @Description:    注册统计bean
* @Author:         xionghao
* @CreateDate:     2018-07-20
*/
@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class RegistrationStatBean extends JSFListingBean<RegistrationStatRequest,RegistrationStatResponse>{


    private List<String> prdList = Lists.newArrayList();

    @PostConstruct
    private void init() {
        initLazyDataModel();
    }

    private void initLazyDataModel() {
        $ = new RegistrationStatRequest();
        prdList.add("-2000");
        $.setPrd_id(prdList);
        lazyDataModel = new RegistrationStatLazyDataModel($);
    }

    public String translateProducts(String productId){
        if (StringUtils.isNotBlank(productId) && !"全部".equals(productId)){
            return translateProduct(Integer.parseInt(productId));
        }else{
            return productId;
        }
    }
}
